public class Solution3 {
    public static void main(String[] args) {
        int x = 8;
        System.out.println(mySqrt(x));
    }
    public static int mySqrt(int x) {
        //细节
        if( x < 1) {
            return 0;
        }
        long left = 0;
        long right = x;
        while(left < right) {
            long mid = (left + right + 1) / 2;
            if(mid * mid <= x) {
                left = mid;
            }else {
                right = mid - 1;
            }
        }
        return (int)left;
    }
}
